/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.session;

import com.thienloc.omap.entity.BroadcastTemp;
import org.slf4j.LoggerFactory;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author GiangLT
 */
@Stateless
public class BroadcastTempFacade extends AbstractFacade<BroadcastTemp> {

    @PersistenceContext(unitName = "omapPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public BroadcastTempFacade() {
        super(BroadcastTemp.class);
    }

    public void moveDataToBroadcast(int maxRecord) throws Exception {
        try {
            Query q = em.createNativeQuery("BEGIN move_data2_broadcast(p_number=>?); END;");
            q.setParameter(1, maxRecord);
            q.executeUpdate();

        } catch (Exception ex) {
            LoggerFactory.getLogger(ModuleConfigFacade.class.getName()).error("", ex);
            throw ex;
        }
    }
}
